import { ArticleSummaryModel } from '../../../models/articleSummaryModel';

export interface HomeArticleListAction {
    type: "SET_HOMEARTICLELIST";
    payload: ArticleSummaryModel[]
}

export const homeArticleList = (
    state: ArticleSummaryModel[] | undefined,
    action: HomeArticleListAction
): ArticleSummaryModel[] => {
    if (!state) {
        return [{
            title: "title",
            description: "miaoshu",
            date: '2020-1-1',
            cover: 'https://gimg2.baidu.com/image_search/src=http%3A%2F%2F5b0988e595225.cdn.sohucs.com%2Fimages%2F20200218%2Fd277471d9c204059b136c15b67f6ca6c.jpeg&refer=http%3A%2F%2F5b0988e595225.cdn.sohucs.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1637935147&t=981ecc9bab5cb1f64fc4dadb8061702f',
            href: '/article/1',
            seen: 124,
            like: 68,
            comments: 5,
        }];
    }
    switch (action.type) {
        case "SET_HOMEARTICLELIST":
            return [...action.payload];
        default:
            return state;
    }
}
